{extend name="public:base" /}

{block name="content"}

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox ">
                <div class="ibox-content">
                    <div method="post">
                        <div class="box-item">
                            <div class="form-group row">
                                <label class="col-sm-1 col-form-label">结算周期</label>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control" placeholder="请输入结算周期" value="{$info.year}-{$info.month}" disabled>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="box-item">
                            <div class="form-group row">
                                <label class="col-sm-1 col-form-label">周期平台总业绩</label>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control" placeholder="请输入周期平台总业绩" value="{$info.all_price}" disabled>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="box-item">
                            <div class="form-group row">
                                <label class="col-sm-1 col-form-label">结算比例</label>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control" placeholder="请输入结算比例" value="{$info.rate}%" disabled>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="box-item">
                            <div class="form-group row">
                                <label class="col-sm-1 col-form-label">结算金额</label>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control" placeholder="请输入总结算金额" value="{$info.all_price * $info.rate / 100}" disabled>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="box-item">
                            <div class="form-group row">
                                <label class="col-sm-1 col-form-label">叠算总金额</label>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control" placeholder="请输入总结算金额" value="{$info.all_retire_price}" disabled>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>

                        <div class="box-item">
                            <div class="form-group row">
                                <label class="col-sm-1 col-form-label">每人平均叠算金额</label>
                                <div class="col-sm-3">
                                    <input type="text" class="form-control" placeholder="请输入每人平均结算金额" value="{$info.retire_price}" disabled>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                        </div>
                    </div>


                    <div class="row">
                        <div class="col-lg-10">
                            <div class="ibox ">
                                <div class="ibox-title">
                                    <h3>待结算列表</h3>
                                    <div class="ibox-tools">
                                        <a class="collapse-link">
                                            <i class="fa fa-chevron-up"></i>
                                        </a>
                                    </div>
                                </div>

                                <div class="ibox-content">
                                    <div class="table-responsive">
                                        <table class="table table-striped">
                                            <tr>
                                                <th>用户</th>
                                                <th>手机号</th>
                                                <th>会员等级状态</th>
                                                <th>结算金额</th>
                                                <th>结算备注</th>
                                                <th>操作</th>
                                            </tr>
                                            {volist name="wait_retire_user_list" id="vo"}
                                            <tr>
                                                <td>{$vo.username}</td>
                                                <td>{$vo.mobile}</td>
                                                <td>
                                                    {if $vo.is_change_level == 0}
                                                    <span style="font-weight: bold; color: red;">真实</span>
                                                    {else /}
                                                    修改
                                                    {/if}
                                                </td>
                                                <td class="col-lg-2">
                                                    <input type="number" min="0" class="form-control price" value="{$info.retire_price}">
                                                </td>
                                                <td class="col-lg-3">
                                                    <input type="text" maxlength="15" class="form-control remark" value="{$info.year}-{$info.month} 退休基金月结">
                                                </td>
                                                <td>
                                                    <a href="{:url('retireFundSend', ['id' => input('id'), 'user_id' => $vo.id])}" class="btn btn-white btn-sm ajax-bonus">
                                                        <i class="fa fa-send"></i> 结算
                                                    </a>
                                                </td>
                                            </tr>
                                            {/volist}
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-lg-10">
                            <div class="ibox ">
                                <div class="ibox-title">
                                    <h3>已结算列表</h3>
                                    <div class="ibox-tools">
                                        <a class="collapse-link">
                                            <i class="fa fa-chevron-up"></i>
                                        </a>
                                    </div>
                                </div>

                                <div class="ibox-content">
                                    <div class="table-responsive">
                                        <table class="table table-striped">
                                            <tr>
                                                <th>用户</th>
                                                <th>手机号</th>
                                                <th>会员等级状态</th>
                                                <th>结算金额</th>
                                                <th>结算备注</th>
                                            </tr>
                                            {volist name="retire_user_list" id="vo"}
                                            <tr>
                                                <td>{$vo.username}</td>
                                                <td>{$vo.mobile}</td>
                                                <td>
                                                    {if $vo.is_change_level == 0}
                                                    <span style="font-weight: bold; color: red;">真实</span>
                                                    {else /}
                                                    修改
                                                    {/if}
                                                </td>
                                                <td>{$vo.price}</td>
                                                <td>{$vo.remark}</td>
                                            </tr>
                                            {/volist}
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

{/block}

{block name='js'}
<script type="text/javascript" src="__PLUG__/kindeditor/kindeditor-all.js"></script>
<script>
    // 结算
    $('.ajax-bonus').click(function () {
        var msg = $(this).data('msg') ? $(this).data('msg') : '您确认结算吗？';
        var url = $(this).attr("href");

        var index = $(this).index('.ajax-bonus');
        var price = $('.price').eq(index).val();
        var remark = $('.remark').eq(index).val();

        swal({
            title: msg,
            cancelButtonText: '取消',
            showCancelButton: true,
            confirmButtonColor: "#1BBF80",
            confirmButtonText: "确认结算",
            closeOnConfirm: false
        }, function () {
            // 加载层
            var index = layer.load(2, {shade: [0.2, '#000']});

            $.get(url, {price: price, remark: remark}, function (res) {
                  if (res.result == 1) {
                      setTimeout(function () {
                          window.location.reload();
                      }, res.timer)
                  } else if (res.result == 2) {
                      layer.close(index);
                      layer.msg(res.msg);
                  }
              }, 'json'
            );

            setTimeout(function () {
                layer.close(index);
            }, 3000)
        });
        return false;
    })
</script>
{/block}
